 /*
  * Mango CMS
  * Copyright 2008, Mango Web, and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
package org.mangocms.model.system;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.mangocms.model.user.User;

/**
 * A system alert raised by Mango itself
 * 
 * @author <a href="tanordheim@gmail.com">Trond Arve Nordheim</a>
 * @version $Revision: 1.1 $
 */
@Entity
@Table(name = "mango_system_alerts")
public class SystemAlert implements Serializable {

	private static final long serialVersionUID = 1L;

	@Column(name = "id")
	@Id @GeneratedValue
	private Integer id;
	
	@Column(name = "component")
	@Length(max = 255)
	@NotNull
	private String component;
	
	@Column(name = "url")
	@Length(max = 255)
	private String url;

	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", referencedColumnName = "id")
	private User user;
	
	@Lob
	@NotNull
	private String description;
	
	@Lob
	private String stackTrace;
	
	@Column(name = "time")
	@NotNull
	private Date time;
	
	@Column(name = "read_time")
	private Date readTime;
	
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "read_by_id", referencedColumnName = "id")
	private User readBy;

	@Column(name = "is_read")
	@NotNull
	private Boolean read = false;
	
	/**
	 * Create a new SystemAlert.
	 */
	public SystemAlert() {
	}

	/**
	 * Get the id.
	 * 
	 * @return the id.
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * Set the id.
	 * 
	 * @param id The id to set.
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * Get the component.
	 * 
	 * @return the component.
	 */
	public String getComponent() {
		return component;
	}

	/**
	 * Set the component.
	 * 
	 * @param component The component to set.
	 */
	public void setComponent(String component) {
		this.component = component;
	}

	/**
	 * Get the url.
	 * 
	 * @return the url.
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * Set the url.
	 * 
	 * @param url The url to set.
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * Get the user.
	 * 
	 * @return the user.
	 */
	public User getUser() {
		return user;
	}

	/**
	 * Set the user.
	 * 
	 * @param user The user to set.
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * Get the description.
	 * 
	 * @return the description.
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Set the description.
	 * 
	 * @param description The description to set.
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Get the stackTrace.
	 * 
	 * @return the stackTrace.
	 */
	public String getStackTrace() {
		return stackTrace;
	}

	/**
	 * Set the stackTrace.
	 * 
	 * @param stackTrace The stackTrace to set.
	 */
	public void setStackTrace(String stackTrace) {
		this.stackTrace = stackTrace;
	}

	/**
	 * Get the time.
	 * 
	 * @return the time.
	 */
	public Date getTime() {
		return time;
	}

	/**
	 * Set the time.
	 * 
	 * @param time The time to set.
	 */
	public void setTime(Date time) {
		this.time = time;
	}

	/**
	 * Get the readTime.
	 * 
	 * @return the readTime.
	 */
	public Date getReadTime() {
		return readTime;
	}

	/**
	 * Set the readTime.
	 * 
	 * @param readTime The readTime to set.
	 */
	public void setReadTime(Date readTime) {
		this.readTime = readTime;
	}

	/**
	 * Get the readBy.
	 * 
	 * @return the readBy.
	 */
	public User getReadBy() {
		return readBy;
	}

	/**
	 * Set the readBy.
	 * 
	 * @param readBy The readBy to set.
	 */
	public void setReadBy(User readBy) {
		this.readBy = readBy;
	}

	/**
	 * Get the read.
	 * 
	 * @return the read.
	 */
	public Boolean getRead() {
		return read;
	}

	/**
	 * Set the read.
	 * 
	 * @param read The read to set.
	 */
	public void setRead(Boolean read) {
		this.read = read;
	}

}
